#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>
#include <cmath>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 1e3 + 10;

int n, h, r;
struct Seg{
    LL x, y, z;
}seg[N];
int p[N];

int find(int x){
    if(p[x] != x){
        p[x] = find(p[x]);
    }
    return p[x];
}

void init(){
    for(int i = 1; i <= n + 2; i ++) p[i] = i;
}

double f(int i, int j){
    double x = (seg[i].x - seg[j].x) * (seg[i].x - seg[j].x);
    double y = (seg[i].y - seg[j].y) * (seg[i].y - seg[j].y);
    double z = (seg[i].z - seg[j].z) * (seg[i].z - seg[j].z);

    return sqrt(x + y + z);
}

void solve(){
    cin >> n >> h >> r;
    
    init();
    for(int i = 1; i <= n; i ++) cin >> seg[i].x >> seg[i].y >> seg[i].z;

    for(int i = 1; i <= n; i ++){
        if(seg[i].z <= r){
            int fa = find(i), fb = find(n + 1);
            if(fa != fb){
                p[fa] = fb; 
            }
        }

        if(seg[i].z + r >= h){
            int fa = find(i), fb = find(n + 2);
            if(fa != fb){
                p[fa] = fb;
            }
        }
    }

    for(int i = 1; i <= n; i ++){
        for(int j = i + 1; j <= n; j ++){
            double len = f(i, j);
            if(len <= 2.0 * r){
                int fa = find(i), fb = find(j);
                if(fa != fb){
                    p[fa] = fb;
                }
            }
        }
    }

    int f0 = find(n + 1), f1 = find(n + 2);
    if(f0 == f1) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--){
        solve();
    }

    return 0;
}